package com.car.rental.user.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.car.rental.user.entity.DriverLicense;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.Param;

import java.util.List;

@Mapper
public interface DriverLicenseMapper extends BaseMapper<DriverLicense> {
    
    /**
     * 根据用户ID查询驾驶证信息
     */
    @Select("SELECT * FROM driver_license WHERE user_id = #{userId}")
    List<DriverLicense> selectListByUserId(@Param("userId") Long userId);
    
    /**
     * 根据驾驶证号码查询驾驶证信息
     */
    @Select("SELECT * FROM driver_license WHERE license_number = #{licenseNumber}")
    DriverLicense selectByLicenseNumber(@Param("licenseNumber") String licenseNumber);

    @Update("UPDATE driver_license SET status = #{status}, remark = #{remark} WHERE user_id = #{userId}")
    int updateByUserId(DriverLicense driverLicense);

    @Update("UPDATE driver_license SET status = #{status}, remark = #{remark} WHERE user_id = #{userId} AND license_number = #{licenseNumber}")
    int updateByUserIdAndLicenseNumber(DriverLicense driverLicense);
} 